package com.code.leetcode.center50;

import com.code.leetcode.utils.TreeNode;

/**
 * @author codeDorado
 * @version 1.0
 * @date 2020/7/26 8:59
 */
public class The104 {

    int x = 0;

    public int maxDepth(TreeNode root) {
        dfs(root, 1);
        return x;
    }

    public void dfs(TreeNode node, int deep) {
        if (node == null) {
            x = Math.max(deep - 1, x);
            return;
        }
        dfs(node.left, deep + 1);
        dfs(node.right, deep + 1);
    }
}
